package com.example.second_home_work

import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.ScrollView
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {

    private val expert = ProgramExpert()
    private lateinit var scrollView: ScrollView
    private lateinit var container:LinearLayout
    private lateinit var button: Button
    private var clickCount = 0
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)

        scrollView = findViewById(R.id.scroll_view)
        container = findViewById(R.id.container)
        button = findViewById(R.id.button)

        button.setOnClickListener {
            clickCount++;
            val infoText = "This is a new textView:$clickCount"
            val text1 = TextView(this).apply{
                this.text = infoText
                layoutParams = LinearLayout.LayoutParams(
                    LinearLayout.LayoutParams.MATCH_PARENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT
                )
            }
            container.addView(text1)
        }

        val button2 = findViewById<Button>(R.id.button2)
        button2.setOnClickListener {
            val spinner = findViewById<Spinner>(R.id.spinner)
            val textView = findViewById<TextView>(R.id.textView)
            textView.text = expert.getLanguage(spinner.selectedItem.toString())
        }

    }
}